Robo Roach Part 2


Output Devices Project

Overview

For Output Devices week, I designed a second board that connected to the input board I built previously. The input board handled all the sensing: each phototransistor fed into a non-inverting op-amp stage, and the XIAO RP2040 read the resulting voltages through two ADC pins. For this week, I focused on how those sensor readings could control the movement of the robot. The motors only needed to spin in one direction, and the robot's behavior could be controlled just by varying the relative speed of the two motors. Brighter light on one side meant that motor should spin faster, causing the RoboRoach to either turn or back away depending on how the light was distributed. This meant I didn't need H-bridges, just a motor driver capable of switching each motor on and off and allowing speed control through PWM.
By splitting the robot into an input board and an output board, I was able to test and debug the sensing and motion systems separately before combining them into the final photophobic RoboRoach.

Board Design

For RoboRoach, my goal is to turn light intensity into an analog signal that becomes greater in magnitude as the robot is exposed to brighter light to mimick a cockroach trying to escape illumination. To do this, I used a phototransistor as a light sensor, an op-amp amplifier, and an MCU to read the output voltages from the op-amps. The phototransistor is placed in a voltage divider so that it produces a larger current as light intensite increases, which causes an increase in the voltage drop across the resistor that is in series with it. That raw signal is very small, so I added an op-amp gain stage to amplify the voltage from the light sensor into something the system can actually react to. The final output from the op-amp goes to the MCU so I can read it on my computer and eventually process it to dictate the behaviour of the robot.

The hand-drawn schematic below shows the main blocks of the circuit: the phototransistor voltage divider, the gain stage, and the mcu.



I also created the schematic and layout in KiCad that I used for milling and assembly.


Testing

Having confirmed from last week that the MCU was receiving clean sensor values, I wrote a simple code for the RoboRoach's behavioral logic. Download here. Based on which side was brighter, the code decided whether the robot should “go left,” “go right,” or “back up.” Instead of driving actual motors at this stage, I routed the two “motor output” pins from the ESP32-C3 to an oscilloscope.

Watching the oscilloscope traces allowed me to see the exact voltage changes the MCU was producing in response to different lighting conditions. When I illuminated one sensor, I could clearly see the corresponding output pin switch to the “turn away” signal; when both sensors got bright, the output for “back up” activated instead. This confirmed that the logic, the sensing, and the control outputs all aligned.



Soldering

For this week, the only real soldering task was attaching the motors. I tinned the motor pads, soldered each motor lead to its designated output point, and then checked the joints with a multimeter to make sure the connections were solid and there were no shorts. With the motors attached, the board was fully assembled and ready for movement testing.



Final Product

To bring my cockroach robot to life, I did some quick cad of the body of a cockroach and mounted the PCB onto it. Download CAD file here.



Here is the completed project.